package com.sql.azarias.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;

import com.sql.azarias.R;
import com.sql.azarias.views.ScrollZoomRecyclerView;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.adapter.recyclerview.wrapper.HeaderAndFooterWrapper;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/2/27.
 */

public class ScrollActivity extends BaseActivity {
    private ScrollZoomRecyclerView acroll_recyclerview;
    private CommonAdapter<String> mAdapter;
    private List<String> mDatas = new ArrayList<>();
    private HeaderAndFooterWrapper mHeaderAndFooterWrapper;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scroll);
        acroll_recyclerview = (ScrollZoomRecyclerView)findViewById(R.id.acroll_recyclerview);
        mDatas.add("-------------"); mDatas.add("-------------");
        mDatas.add("-------------"); mDatas.add("-------------");
        mDatas.add("-------------"); mDatas.add("-------------");

        acroll_recyclerview.setLayoutManager(new LinearLayoutManager(this));
        //acroll_recyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));



        mAdapter = new CommonAdapter<String>(this, android.R.layout.simple_list_item_1,mDatas) {
            @Override
            protected void convert(ViewHolder holder, String s, int position) {
                holder.setText(android.R.id.text1,s);
            }
        };
        mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(mAdapter);
        View headerView = View.inflate(this, R.layout.itme_space_header, null);
        ImageView ivBackground = (ImageView) headerView.findViewById(R.id.ivBackground);
        mHeaderAndFooterWrapper.addHeaderView(headerView);
        acroll_recyclerview.setZoomImageView(ivBackground);
        acroll_recyclerview.setAdapter(mHeaderAndFooterWrapper);

    }
    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        super.onWindowFocusChanged(hasWindowFocus);
        if (hasWindowFocus) {
            acroll_recyclerview.setViewsBounds();
        }

    }

}
